/*
* Copyright (C) 2012-2014 qar
* License: http://www.gnu.org/licenses/gpl.html GPL version 2
*/

#include "crypto/hash/hashfunctionmd5.h"

HashFunctionMd5::HashFunctionMd5()
    : qHasher(QCryptographicHash::Md5)
{}

HashFunctionMd5::~HashFunctionMd5()
{}

qint64 HashFunctionMd5::hashSize() const
{
    return 16;
}

QString HashFunctionMd5::getAlgorithmName() const
{
    return "MD5";
}

void HashFunctionMd5::reset()
{
    qHasher.reset();
}

void HashFunctionMd5::addData(const char *data, int length)
{
    qHasher.addData(data, length);
}

QByteArray HashFunctionMd5::result() const
{
    return qHasher.result();
}

QByteArray HashFunctionMd5::offlineHash(const QByteArray &data) const
{
    return QCryptographicHash::hash(data, QCryptographicHash::Md5);
}
